#!/usr/bin/env python
#
#       Clouds.py
#       
#       Copyright 2009 Pete Lord <mr.petelord@gmail.com>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

import os
import pygame
import random

import Objects
import Options

class Cloud(Objects.Object):
    def __init__(self, parent, x, y, colour):
        Objects.Object.__init__(self,x, y, 0)
        self.parent = parent
        self.colour = colour
        self.graphic = pygame.image.load(os.path.join('Data', 'Nothing.png')) # main thing.
        self.pencil = pygame.Surface((1,1))
        self.pencil.fill(self.colour)

        self.cross = pygame.image.load(os.path.join('Data', 'Nothing.png'))
        pygame.transform.scale(self.cross, (3,3))
        #self.pencil.set_alpha(255)
        #self.cross.blit(self.pencil, (1, 1))
        self.pencil.set_alpha(150)
        #self.cross.blit(self.pencil, (1, 0))
        #self.cross.blit(self.pencil, (1, 2))
        #self.cross.blit(self.pencil, (0, 1))
        #self.cross.blit(self.pencil, (2, 1))
        
        tempx = 0
        tempy = 0
        for i in range(0, (50*50)):
            #self.pencil.set_alpha(random.randint(0,255))
            self.cross.blit(self.pencil, (tempx, tempy))
            if (tempx > x):
                tempy += 1
            
        self.pencil.set_alpha(20)
        self.cross.blit(self.pencil, (5, 5))
        self.cross.blit(self.pencil, (5, 6))
        self.cross.blit(self.pencil, (5, 7))
        self.cross.blit(self.pencil, (5, 8))
        self.cross.blit(self.pencil, (5, 9))
        self.cross.blit(self.pencil, (5, 10))
        self.cross.blit(self.pencil, (6, 5))
        self.cross.blit(self.pencil, (6, 6))
        self.cross.blit(self.pencil, (6, 7))
        self.cross.blit(self.pencil, (6, 8))
        self.cross.blit(self.pencil, (6, 9))
        self.cross.blit(self.pencil, (6, 10))
        self.cross.blit(self.pencil, (7, 5))
        self.cross.blit(self.pencil, (7, 6))
        self.cross.blit(self.pencil, (7, 7))
        self.cross.blit(self.pencil, (7, 8))
        self.cross.blit(self.pencil, (7, 9))
        self.cross.blit(self.pencil, (7, 10))
        self.cross.blit(self.pencil, (8, 5))
        self.cross.blit(self.pencil, (8, 6))
        self.cross.blit(self.pencil, (8, 7))
        self.cross.blit(self.pencil, (8, 8))
        self.cross.blit(self.pencil, (8, 9))
        self.cross.blit(self.pencil, (8, 10))
        self.cross.blit(self.pencil, (9, 5))
        self.cross.blit(self.pencil, (9, 6))
        self.cross.blit(self.pencil, (9, 7))
        self.cross.blit(self.pencil, (9, 8))
        self.cross.blit(self.pencil, (9, 9))
        self.cross.blit(self.pencil, (9, 10))
        self.cross.blit(self.pencil, (10, 5))
        self.cross.blit(self.pencil, (10, 6))
        self.cross.blit(self.pencil, (10, 7))
        self.cross.blit(self.pencil, (10, 8))
        self.cross.blit(self.pencil, (10, 9))
        self.cross.blit(self.pencil, (10, 10))
        

        
        
                
        self.graphic.convert_alpha()
        self.pencil.convert_alpha()
        
    def clear(self):
        self.graphic = pygame.Surface((64,64))
        
    def set_alpha(self, x, y, value):
        self.pencil.set_alpha(value)
        self.graphic.blit(self.pencil, (x, y))
    
    def set_alpha_cross(self, x, y, value):
        # MINIMUM OF x = 1, y = 1, MAXIMUM OF x = 63, y = 63
        self.cross.set_alpha(value)
        self.graphic.blit(self.cross, (x-1 , y-1))
        
    def set_alphas(self, list):
        # pass this a list of tuples with (x, y, value) and it'll do them all. Woo!
        for item in list:
            self.set_alpha(item[0], item[1], item[2])
            
    def set_alphas_cross(self, list):
        # pass this a list of tuples with (x, y, value) and it'll do them all. Woo!
        for item in list:
            self.set_alpha_cross(item[0] -1 , item[1] -1, item[2])